<?php


class Category extends Record {       
	protected $table = Options::DB_TABLE_CATEGORIES;
	
	public function scopeLanguage($query) {
		return $query->leftJoin(Options::DB_TABLE_LANGUAGES, function($join) {
				      $join->on(Options::DB_TABLE_CATEGORIES.'.languageID', '=', Options::DB_TABLE_LANGUAGES.'.id');
				    })->where(Options::DB_TABLE_LANGUAGES.'.code', '=', Config::get('app.locale') );
	}
	/*public function scopeStatus($query,$criteria) {
		return $query->where('status', '=', $criteria );
	}*/	
	public function scopeOrderBySequence($query,$criteria) {
		return $query->orderBy('sequence', $criteria );
	}
	public function addNew(){            
        return $this->save();
    }
	public function getListCategory(){
		return DB::table(Options::DB_TABLE_CATEGORIES)->where('status','=','1')->orderBy('id', 'asc')->lists('name','id');
	}
}